# coding=utf-8
from .common import ConfigBase
from ...server import compFactory, levelId

_extraDataComp = compFactory.CreateExtraData(levelId)


class Config(ConfigBase):

    @classmethod
    def create(cls):
        self = cls()
        data = _extraDataComp.GetExtraData(cls.getKey())
        if isinstance(data, dict):
            self.deserialize(data)
        return self

    def persistence(self):
        _extraDataComp.SetExtraData(self.getKey(), self.serialize())
